package com.zhike.api.controller.reportfeedback;

import com.zhike.common.dto.R;
import com.zhike.common.model.Feedback;
import com.zhike.common.vo.UserInfo4Cache;
import com.zhike.service.reportfeedback.ZhikeUserFeedBackService;
import com.zhike.service.system.ISystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("api/zkim/user/feedback")
@Api(tags = "用户意见反馈模块")
public class FeedBackController {

    @Resource
    private ZhikeUserFeedBackService zhikeUserFeedBackService;

    @Autowired
    private ISystemService systemService;

    @ApiOperation(value = "提交反馈")
    @PostMapping("addFeedback")
    public R<Boolean> addFeedback(@Validated @RequestBody Feedback dto) {
        UserInfo4Cache rdsUser = systemService.getUserInfo();
        dto.setUserId(rdsUser.getFakeUid());
        return R.success(zhikeUserFeedBackService.addFeedback(dto));
    }
}
